/**
 * Author(s): xuming.Wong <xuming.Wong@gmail.com>
 */
#include "DBIndexFile.h"

namespace QSThink
{
	//read or write all to disk for simplicity
	DBIndexFile::DBIndexFile()
	{
		_indexShangHai=new StockIndexImage(Exchange_ShangHai);
		_indexShenZhen=new StockIndexImage(Exchange_ShenZhen);

		
	}

	int DBIndexFile::persist(int symbol,const char* name,int nameLen)
	{
		ExchangeType ex=Utilities::getExchangeBySymbol(symbol);
		switch(ex){
			case Exchange_ShangHai:
				return _indexShangHai->persist(symbol,name,nameLen);
			case Exchange_ShenZhen:
				return _indexShenZhen->persist(symbol,name,nameLen);
		}

		return -1;


	}

	int DBIndexFile::getSymbolIndex( int symbol )
	{

		ExchangeType ex=Utilities::getExchangeBySymbol(symbol);
		switch(ex){
			case Exchange_ShangHai:
				return _indexShangHai->getSymbolIndex(symbol);
			case Exchange_ShenZhen:
				return _indexShenZhen->getSymbolIndex(symbol);
		}

		return -1;


	}

	std::string DBIndexFile::getStockName( int symbol )
	{
		ExchangeType ex=Utilities::getExchangeBySymbol(symbol);
		switch(ex){
			case Exchange_ShangHai:
				return _indexShangHai->getStockName(symbol);
			case Exchange_ShenZhen:
				return _indexShenZhen->getStockName(symbol);
		}

		return "";
	}

}
